package com.platform.user.controller;

import com.platform.bean.Result;
import com.platform.user.dao.ChatUserDao;
import com.platform.user.entity.ChatUser;
import com.platform.user.entity.User;
import com.platform.user.service.ChatRoomService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/chatRoom")
public class ChatRoomController {

    @Resource
    private ChatRoomService chatRoomService;

    @PostMapping("queryUserIfInRoom")
    public Result<Map<String, Object>> queryUserIfInRoom(@RequestBody Map<String, Object> params) {
        int i = chatRoomService.queryUserIfInRoom(params);
        return Result.ok(i);
    }

    @PostMapping("applyEnterChatRoom")
    public Result<Map<String, Object>> applyEnterChatRoom(@RequestBody Map<String, Object> params) {
        chatRoomService.applyEnterChatRoom(params);
        return Result.ok("申请成功");
    }

    @PostMapping("queryChatRoomEnterApplication")
    public Result<Map<String, Object>> queryChatRoomEnterApplication(@RequestBody Map<String, Object> params) {
        return Result.ok(chatRoomService.queryChatRoomEnterApplication(params));
    }

    @PostMapping("queryChatRoomList")
    public Result<Map<String, Object>> queryChatRoomList(@RequestBody Map<String, Object> params) {
        return Result.ok(chatRoomService.queryChatRoomList(params));
    }

    @PostMapping("handleEnterChatRoomApplication")
    public Result<Map<String, Object>> handleEnterChatRoomApplication(@RequestBody Map<String, Object> params) {
        chatRoomService.handleEnterChatRoomApplication(params);
        return Result.ok("ok");
    }

    @PostMapping("queryRoomMember")
    public Result<Map<String, Object>> queryRoomMember(@RequestBody Map<String, Object> params) {
        return Result.ok(chatRoomService.queryRoomMember(params));
    }

    @PostMapping("queryItemByRoomId")
    public Result<Map<String, Object>> queryItemByRoomId(@RequestBody Map<String, Object> params) {
        return Result.ok(chatRoomService.queryItemByRoomId(params));
    }

    @PostMapping("exitChatRoom")
    public Result<Map<String, Object>> exitChatRoom(@RequestBody Map<String, Object> params) {
        chatRoomService.exitChatRoom(params);
        return Result.ok("ok");
    }
}
